package org.lennon.action;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.lennon.service.ParseLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("statistics")
public class StatisticAction {

	@Autowired
	private ParseLog parse;

	@RequestMapping("line")
	@ResponseBody
	public List<Map<String, Integer>> getLineData(String project, Date date) {
		return parse.getLineData(project, new SimpleDateFormat("yyyy/MM/dd").format(date));
	}

	@RequestMapping("getProjectList")
	@ResponseBody
	public List<String> getProjectList() {
		return parse.getProjectList();
	}

	@RequestMapping("getReqMethodData")
	@ResponseBody
	public List<Map<String, Integer>> getReqMethodData(String project, Date date) {
		return parse.getReqMethodData(project, new SimpleDateFormat("yyyy/MM/dd").format(date));
	}

	@RequestMapping("getReqResultData")
	@ResponseBody
	public List<Map<String, Integer>> getReqResultData(String project, Date date) {
		return parse.getReqResultData(project, new SimpleDateFormat("yyyy/MM/dd").format(date));
	}

	@RequestMapping("getReqTypeData")
	@ResponseBody
	public List<Map<String, Integer>> getReqTypeData(String project, Date date) {
		return parse.getReqTypeData(project, new SimpleDateFormat("yyyy/MM/dd").format(date));
	}

	@RequestMapping("getTopVisit")
	@ResponseBody
	public List<Map<String, Integer>> getTopVisit(String project, int number) {
		return parse.getTopVisit(project, number);
	}

	@RequestMapping("getTopBytes")
	@ResponseBody
	public List<Map<String, Integer>> getTopBytes(String project, int number) {
		return parse.getTopBytes(project, number);
	}

	@RequestMapping("getTopPage")
	@ResponseBody
	public List<Map<String, Object>> getTopPage(String project, int number) {
		return parse.getTopPage(project, number);
	}

	@RequestMapping("getTopSlowPage")
	@ResponseBody
	public List<Map<String, Object>> getTopSlowPage(String project, int number) {
		return parse.getTopSlowPage(project, number);
	}

}
